package demo7;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class Test {
    public static void main(String[] args) {
        System.out.println("创建Spring容器");
        AnnotationConfigApplicationContext context1
                = new AnnotationConfigApplicationContext("demo7");
        System.out.println("Spring容器创建完毕");
        User u = context1.getBean(User.class);
        System.out.println("通过Spring容器获取到对象:"+u);
        System.out.println("使用User对象进行实际操作");

        System.out.println("最终关闭Spring容器");
        context1.close();
    }
}
